<?php
	class Ttvalidation {
		const EMAIL_PATTERN = '/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/';
		public function prepare_string($val) {
			return htmlspecialchars(trim($val));	
		}
		
		public function matches($val, $pattern) {
			return preg_match($pattern, $val);
		}
		
		public function matches_email($email) {
			return preg_match(self::EMAIL_PATTERN, $email);
		} 
		
		public function trim($val) {
			return trim($val);
		}
	}
?>